package cn.home.sysmanagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.home.common.annotation.Log;
import cn.home.common.core.controller.BaseController;
import cn.home.common.core.domain.AjaxResult;
import cn.home.common.enums.BusinessType;
import cn.home.sysmanagement.domain.HomeDoctorTag;
import cn.home.sysmanagement.service.IHomeDoctorTagService;
import cn.home.common.utils.poi.ExcelUtil;
import cn.home.common.core.page.TableDataInfo;

/**
 * 医生-标签Controller
 * 
 * @author homedoctor
 * @date 2025-04-14
 */
@RestController
@RequestMapping("/sysmanagement/doctag")
public class HomeDoctorTagController extends BaseController
{
    @Autowired
    private IHomeDoctorTagService homeDoctorTagService;

    /**
     * 查询医生-标签列表
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctag:list')")
    @GetMapping("/list")
    public TableDataInfo list(HomeDoctorTag homeDoctorTag)
    {
        startPage();
        List<HomeDoctorTag> list = homeDoctorTagService.selectHomeDoctorTagList(homeDoctorTag);
        return getDataTable(list);
    }

    /**
     * 导出医生-标签列表
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctag:export')")
    @Log(title = "医生-标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HomeDoctorTag homeDoctorTag)
    {
        List<HomeDoctorTag> list = homeDoctorTagService.selectHomeDoctorTagList(homeDoctorTag);
        ExcelUtil<HomeDoctorTag> util = new ExcelUtil<HomeDoctorTag>(HomeDoctorTag.class);
        util.exportExcel(response, list, "医生-标签数据");
    }

    /**
     * 获取医生-标签详细信息
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctag:query')")
    @GetMapping(value = "/{doctorId}")
    public AjaxResult getInfo(@PathVariable("doctorId") Long doctorId)
    {
        return success(homeDoctorTagService.selectHomeDoctorTagByDoctorId(doctorId));
    }

    /**
     * 新增医生-标签
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctag:add')")
    @Log(title = "医生-标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HomeDoctorTag homeDoctorTag)
    {
        return toAjax(homeDoctorTagService.insertHomeDoctorTag(homeDoctorTag));
    }

    /**
     * 修改医生-标签
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctag:edit')")
    @Log(title = "医生-标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HomeDoctorTag homeDoctorTag)
    {
        return toAjax(homeDoctorTagService.updateHomeDoctorTag(homeDoctorTag));
    }

    /**
     * 删除医生-标签
     */
    @PreAuthorize("@ss.hasPermi('sysmanagement:doctag:remove')")
    @Log(title = "医生-标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{doctorIds}")
    public AjaxResult remove(@PathVariable Long[] doctorIds)
    {
        return toAjax(homeDoctorTagService.deleteHomeDoctorTagByDoctorIds(doctorIds));
    }
}
